package com.walter.learn.TestUtil;

import com.walter.learn.Util.ConvertPhotoToWebpByCmd;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

import static com.walter.learn.Util.ConvertPhotoToWebpByCmd.executeCWebp;
import static com.walter.learn.Util.FileUtils.getFilesList;

/**
 * @ProjectName: learn
 * @Package: com.walter.learn.TestUtil
 * @ClassName: ConvertPhotoToWebpByCmdTest
 * @Author: DELL
 * @Description: ${description}
 * @Date: 2019/8/15 18:25
 * @Version: 1.0
 */
public class ConvertPhotoToWebpByCmdTest {

    private static String resultType_NameAbsolutePath = "absolutePath";
    private static String webpSuffix=".webp";
    @Test
    public void test(){
        String inputFile="E:\\imagesToWebp\\123.gif";
        String outputFile="E:\\imagesToWebp\\123.webp";
        Integer quality=0;
        executeCWebp(inputFile,outputFile,quality);
    }
    @Test
    public void testBatch(){

        String filePath="E:\\imagesToWebp\\test";
        List<String> list=new ArrayList<>();
        getFilesList(filePath,"*",resultType_NameAbsolutePath,list);
        Integer quality=0;
        for(String s:list){
            //将文件生成1.png---》1.webp  不覆盖
            executeCWebp(s,s.substring(0,s.indexOf("."))+webpSuffix,quality);
        }

    }
}
